package com.shelpe.services.sinbad.controller;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.shelpe.services.sinbad.model.Keyword;
import com.shelpe.services.sinbad.model.RptKeyword;

import lombok.Data;

@Data
public class EffectableKeywordDto {
	@JsonProperty("keyword_id")
	private long keywordID;
	private String word;
	
	@JsonProperty("adgroup_id")
	private long adgroupID;
	
	@JsonProperty("max_price")
	private float maxPrice;
	@JsonProperty("max_mobile_price")
	private float maxMobilePrice;
	@JsonProperty("impressions")
	private int impression;//展现量
	@JsonProperty("matchscope")
	private int matchScope;
	private int click;//点击量
	@JsonProperty("ctr")
	private float clickRatio;//点击率
	private float cpc;//平均点击花费
	private float cpm;
	private float cvr;//点击转化率
	@JsonProperty("avgpos")
	private int productRanking;//宝贝排名
	private int qscore;//质量得分
	@JsonProperty("wireless_qscore")
	private int mobileQscore;//移动质量得分
	private float cost;//总花费
	@JsonProperty("sales")
	private float sale;//总金额
	@JsonProperty("total_pay_count")
	private int payCount;//成交笔数
	private float roi;//投入产出比
	@JsonProperty("fav_count")
	private int favCount;//收藏数
	@JsonProperty("fav_count_rate")
	private float favCountRatio;//收藏率
	@JsonProperty("cart_count")
	private int cartCount;//购物车数
	@JsonProperty("cart_count_rate")
	private float cartCountRatio;//购物车率
	@JsonProperty("is_default_price")
	private boolean asDefaultPrice;
	@JsonProperty("is_default_mobile_price")
	private boolean asDefaultMobilePrice;
	
	public void from(Keyword word){
		this.setWord(word.getWord());
		this.setMaxPrice(word.getMaxPrice());
		this.setMaxMobilePrice(word.getMaxMobilePrice());
		this.setMatchScope(word.getMatchscope());
		this.setKeywordID(word.getKeywordId());
		this.setMobileQscore(word.getWirelessQscore());
		this.setQscore(word.getQscore());
		this.setAsDefaultPrice(word.getIsDefaultPrice());
		this.setAsDefaultMobilePrice(word.getMobileIsDefaultPrice() == 1 ? true : false);
		
		this.setAdgroupID(word.getAdgroupId());
	}
	
	public void from(RptKeyword rptKeyword){
		this.setClick(rptKeyword.getClick());
		this.setImpression(rptKeyword.getImpressions());
		this.setCvr(rptKeyword.getCvr());
		this.setCartCountRatio(rptKeyword.getCartCountRate());
		this.setFavCountRatio(rptKeyword.getFavCountRate());
		this.setProductRanking(rptKeyword.getAvgpos().intValue());
		this.setFavCount(rptKeyword.getFavItemCount() + rptKeyword.getFavShopCount());
		this.setPayCount(rptKeyword.getPayCount());
		this.setSale(rptKeyword.getSale());
		this.setRoi(rptKeyword.getRoi());
		this.setCpc(rptKeyword.getCpc());
		this.setCpm(rptKeyword.getCpm());
		this.setCartCount(rptKeyword.getCartTotal());
		this.setCost(rptKeyword.getCost());
		this.setClickRatio(rptKeyword.getCtr());
	}
	
}
